<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>P70D4d1</title>
</head>

<body>
	<script>
	var arr=['1','2','3','4','2','5','6','2','7','2'];
var res=[];
	for(var j=0;j<arr.length;j++){
		if(arr[j]==2){
			res.push(arr[j])
		}
	
	}
	console.log("新数组为："+res);
	</script>
</body>
</html>
